package com.hgx.common.exception;

/**
 * 公共异常处理类
 */
public class CommonException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private String msg;
    private String code = "500";
    private Object data;

    public CommonException(String msg) {
        this.msg = msg;
    }

    public CommonException(String code, String msg) {
        this.msg = msg;
        this.code = code;
    }

    public CommonException(String code, String msg, Object data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    public CommonException(String code, String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }


    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String toString() {
        return "CommonException{" +
                "msg='" + msg + '\'' +
                ", code=" + code +
                ", data=" + data +
                '}';
    }
}
